package com.yidu.StockControl.mapper;

import com.yidu.StockControl.entity.CashInventory;
import com.yidu.StockControl.entity.TAInventory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/*
 TA库存
 */
@Repository
public interface TAInventoryMapper {

    @Select("select * from TAInventory WHERE 1=1 ${strWhere} LIMIT #{page},#{limit}")
    public List<TAInventory> selectTAInventory(Map map);

    @Select("select count(*) from TAInventory")
    int selectTAInventoryCount();

    @Insert("insert into TAInventory values(#{taInventoryId},#{fundId},#{statisticsDate},#{taMoney},#{number})")
    public int insertTAInventory(TAInventory taInventory);

    @Update("update TAInventory set fundId=#{fundId},statisticsDate=#{statisticsDate},taMoney=#{taMoney},number=#{number} where " +
            "taInventoryId=#{taInventoryId}")
    public void updateTAInventory(TAInventory taInventory);

    @Delete("delete from TAInventory where taInventoryId = #{taInventoryId}")
    public void deleteTAInventory(String taInventoryId);

    @Delete("delete from TAInventory where taInventoryId=#{taInventoryId} and fundId = #{fundId} and statisticsDate = DATE_FORMAT(DATE_ADD(STR_TO_DATE(#{dateTime},'%Y-%m-%d'),INTERVAL -1 DAY),'%Y-%m-%d')")
    public int deleteTAInventoryfDate(String taInventoryId, String fundId, String dateTime);
}
